import { defineStore } from 'pinia'

import userInfo from '@/api/userInfo'
import { showFailToast } from 'vant'

export const useUserInfoStore = defineStore('userInfo', {
  state: () => {
    return {
      userInfo: {}
    }
  },
  actions: {
    async getUserInfo() {
      try {
        const res = await userInfo.getUserInfo()
        this.userInfo = res
      } catch (error) {
        showFailToast('获取用户信息失败')
        return Promise.reject('failed')
      }
    }
  }
})
